<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/style_user2.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <script src="__STATIC__/password/passwordBox.min.js"></script>
    <script src="__STATIC__/password/md5.js"></script>
    <title>{eq name=":input('act')" value='forget'}忘记{else/}设置{/eq}支付密码</title>
</head>
<body>
<div class="wrap-phone">
    <div class="header">
        <p>验证手机号</p>
        <img src="__STATIC__/img/back.png" class="back" onclick="back_url()">
    </div>
    <form action="{:url('mobile/pay_pass/bind_act')}" method="post" id="form" onsubmit="return false">
        <div class="center">
            <div>
                <input class="text" type="text" value="{$info.username}" readonly>
            </div>
            <div>
                <input class="text" type="number" name="code" placeholder="验证码" datatype="n6" nullmsg="请填写验证码"
                       errormsg="请填写6位纯数字">
                <span><a href="javascript:check_num();" id="yzm">验证码</a></span>
            </div>
        </div>
        <input type="button" class="submit"  value="下一步">
    </form>
</div>
{include file="public/src" /}
<script>

    // 输入内容判断
    $(function () {
        $.Tipmsg.r = null;
        $.Tipmsg.p = null;
        $.Datatype.n6 = /^\d{6}$/;
        var demo = $("#form").Validform({
            tiptype: function (msg) {
                layer.open({content: msg, skin: 'msg', time: 2});
            },
            btnSubmit: '.submit',
            tipSweep: true,
            ajaxPost: true,
            callback:function (t) {
                if (t.code != 200){
                    layer.open({content:t.message,skin:'msg',time:2});
                }else{
                    setTimeout(function () {
                        window.location.href = "{:url('mobile/pay_pass/check')}?act={:input('act')}";
                    },1000);
                }
            }
        });
        demo.config({
            ajaxpost:{
                error: function () {
                    layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
                }
            }
        });
    });

    //发送验证码
    function check_num() {
        count_down();
        $.ajax({
            url: "{:url('mobile/pay_pass/getVerif')}",
            dataType: 'json',
            type: 'post',
            data: {'tel': '{$info.username}'},
            success: function (t) {
                layer.open({content: '验证码发送成功',skin:'msg',time:2});
            },
            error: function () {
                layer.open({content:'网络繁忙,请重试',skin:'msg',time:2});
            }
        })
    }

    //验证码倒计时
    function count_down() {
        var num = 60;
        var verif = $('#yzm');
        var timer = setInterval(function () {
            verif.text(num + '秒');
            if (num <= 60 && num >= 1) {
                verif.removeAttr('href');
            } else {
                verif.text('重新获取验证码');
                window.clearInterval(timer);
                verif.attr("href", 'javascript:check_num();');
            }
            num--;
        }, 1000);
    }
    //返回
    function back_url(){
        var url = window.location.href;
        if (url.indexOf('paying') > -1){
            window.location.href=sessionStorage.getItem('pay_url');
        }else{
            window.location.href="{:url('mobile/user_info/my_wallet')}"
        }
    }
</script>
</body>

</html>